import {Component, EventEmitter,ViewChild, Input, OnInit, Output} from '@angular/core';
import {Router} from '@angular/router';
import {HttpClient} from '@angular/common/http';
import { InitService } from '../../../public/serve/init/init.service';
import { appTemplateUrl } from '../template.url';
import { template } from '../template.data';
import { RemoveTableService } from '../../../public/serve/remove-table/remove-table.service';
import { Service } from '../../../server/server';
import { HintsService } from '../../../public/serve/hints/hints.service';
import { CudTableService } from '../../../public/serve/cud-table/cud-table.service';
import {MessageService} from 'primeng/api';

@Component({
  selector: 'app-template-path-delete',
  templateUrl: './template-path-delete.component.html',
  styleUrls: ['./template-path-delete.component.css']
})
export class TemplatePathDeleteComponent implements OnInit {

  @Output() delete = new EventEmitter<void>();

  constructor(
    public removeTableService: RemoveTableService,
    private hintsService: HintsService,
    private server: Service
  ) { }

  ngOnInit() {
  }

  /**
   * 删除
   */
  _delete(){

    this.removeTableService
    .confirmRemove('ids',this.server.baseUrl + appTemplateUrl.deleteExportPath,'token',template.retrieval.token)
    .then(res => {
      if(res.result_code == '0000'){
        this.delete.emit();
      }

      this.hintsService.messages(res.message,res.result_code);
      return;
    })
    .catch(err => {
      this.hintsService.messages('error','error');
      return;
    });
  }

}
